package cn.demo.app.gateway;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author: float 2023/7/5 16:43
 */
@Component
public class TeGolbalFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("TeGolbalFilter before");
        return chain.filter(exchange).doFinally(signalType -> {
            System.out.println("TeGolbalFilter after :"+signalType);

//            exchange.getResponse().
        });
//        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 1;
    }
}
